import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description: 奇数放在偶数前面
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-05-01  06:53
 */
public class Test {
    public static void transform(int[] array) {
        int left = 0;
        int right = array.length-1;
        while(left < right) {
            while (left < right && array[left] % 2 != 0) {
                left++;
            }
            while (left < right && array[right] % 2 == 0) {
                right--;
            }
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
        }
    }
    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6};
        transform(array);
        System.out.println(Arrays.toString(array));
    }
}
